@extends('layouts.console_header')

@section('title', '个人地推详情')

@section('resources')
    @parent
	<style>
		.salesman_style .salesman_style_li{overflow: hidden;border-bottom: 1px solid #666;padding: 10px 0;}
		.salesman_style .salesman_style_li ul{float: left;width: 600px;}
		.salesman_style .salesman_style_li ul li{overflow: hidden;margin: 10px 0;}
		.salesman_style .salesman_style_li ul li .title{float: left;width: 100px;text-align: right;margin-right: 10px;font-size: 16px;}
		.salesman_style .salesman_style_li ul li .content{float: left;color: #666;overflow: hidden;font-size: 14px;width: 450px;}
		.salesman_style .salesman_style_li ul li .content .count{float: left;margin-right: 20px;}
		.salesman_style .salesman_style_li ul li .content a{float: right;color: #0000CC;}
		.choose_salesman_way{float: right;background-color: #9955c6;color: #fff;padding: 5px 10px;border-radius: 5px;margin: 15px 15px;cursor: pointer;}
		.prompt_double{width: 500px;position: fixed;top: 200px;left: 50%;margin-left: -250px;background-color: #fff;z-index: 1001;box-shadow: 0px 0px 5px 5px rgba(128,128,128,0.5);display: none;}
        .prompt_double .title{font-size: 24px;margin-top: 10px;color: #9955c6;text-align: center;}
        .prompt_double .content{overflow: hidden;margin: 20px 90px;}
        .prompt_double .content span{float: left;margin-right: 10px;}
        .prompt_double .content select{float: left;border: 1px solid #666;}
        .prompt_double .close_pic{width: 30px;height: 30px;position: absolute;top: 10px;right: 10px;cursor: pointer;}
        .prompt_double .button{margin-top: 30px;font-size: 24px;}
        .prompt_double .button button{width: 100px;height: 40px;text-align: center;line-height: 40px;border-radius: 5px;cursor: pointer;}
        .prompt_double .button .cancel{margin: 10px 0 30px 20px;background-color: #eee;}
        .prompt_double .button .sure{margin: 10px 20px 30px 0;cursor: pointer;}
	</style>
@endsection

@section('content')
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>地推管理><a href="/console/salesman/user/list">个人地推</a>></span>
		    <span class="co_violet">详情</span>
        </p>
		<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
	</div>
	<div class="details1">
		<p>基本信息</p>
		<div class="details1_name">
			<ul class="fl">
				<li>
					<span>姓名</span>
					<span>{{$name}}</span>
				</li>
				<li>
					<span>手机号</span>
					<span>{{$mobile}}</span>
				</li>
				<li>
					<span>备注</span>
					<span>{{$cityname}}用户</span>
				</li>
				<li style="width: 1000px;">
					<span>地推合计</span>
					<span>{{$registernum}}个注册用户 {{$ordernum}}笔订单 {{$ordervalidnum}}笔地推订单 地推订单实付：{{$ordertotalamount}} 地推收入：￥{{$totalmoney}}</span>
				</li>
			</ul>
			<ul class="fl">
				<li>
					<span>创建时间</span>
					<span>{{$created_at}}</span>
				</li>
				<li>
					<span>状态</span>
                @if($status)
					<span>可用</span>
					<button class="cancel_salesman" style="width: 100px;height: 30px;background-color: #9955c6;line-height: 30px;cursor: pointer;">取消地推</button>
                @else
                    <span>不可用</span>
                    <button class="open_salesman" style="width: 100px;height: 30px;background-color: #9955c6;line-height: 30px;cursor: pointer;">开通地推</button>
				@endif
				</li>
			</ul>
		</div>
	</div>
	<div class="details1">
		<div style="overflow: hidden;">
			<p style="float: left;">地推方案</p>
			<span class="choose_salesman_way">变更地推方案</span>
		</div>
    @if(!empty($salesmansetdetail))
		<ul class="salesman_style">
			<li class="salesman_style_li">
				<ul>
					<li>
						<span class="title">生效时间</span>
						<div class="content">{{date('Y-m-d', strtotime($salesmansetdetail['created_at']))}} 至今</div>
					</li>
					<li>
						<span class="title">结算周期</span>
						<div class="content">{{$salesmansetdetail['accountperioddescription']}}</div>
					</li>
					<li>
						<span class="title">个人地推结算</span>
						<div class="content">{{$salesmansetdetail['showaccountmethod']}}</div>
					</li>
				</ul>
				<ul>
					<li>
						<span class="title">地推名称</span>
						<div class="content">{{$salesmansetdetail['name']}}</div>
					</li>
					<li>
						<span class="title">有效地推定义</span>
						<div class="content">{{$salesmansetdetail['showvalidsalesman']}}</div>
					</li>
					<li>
						<span class="title">地推效果</span>
						<div class="content">
							<span class="count">{{$currentregisternum}}个注册用户</span>
                        @if(($salesmansetdetail['accounttype']==2)||($salesmansetdetail['accounttype']==3)||($salesmansetdetail['accounttype'] ==4))
							<span class="count">{{$currentordernum}}笔地推订单</span>
							<span class="count">地推订单实付：{{$currentordertotalamount}}</span>
                        @elseif($salesmansetdetail['accounttype']==5||$salesmansetdetail['accounttype']==6)
							<span class="count">{{$currentrechargenum}}笔充值</span>
                        @endif
							<span class="count">地推收入：￥{{$currenttotalmoney}}</span>
							<a href="/console/salesman/user/result?salesmanid={{$salesmanid}}&cityid={{$cityid}}&salesmansetid={{$salesmansetid}}">查看效果明细>></a>
						</div>
					</li>
				</ul>
			</li>
		</ul>
    @endif
    @if(!empty($lastsalesmansetdetail))
		<ul class="salesman_style">
			<li class="salesman_style_li">
				<ul>
					<li>
						<span class="title">生效时间</span>
						<div class="content">{{date('Y-m-d', strtotime($lastsalesmansetdetail['created_at']))}} 至 {{date('Y-m-d', strtotime($lastsalesmansetdetail['updated_at']))}}</div>
					</li>
					<li>
						<span class="title">结算周期</span>
						<div class="content">{{$lastsalesmansetdetail['accountperioddescription']}}</div>
					</li>
					<li>
						<span class="title">个人地推结算</span>
						<div class="content">{{$lastsalesmansetdetail['showaccountmethod']}}</div>
					</li>
				</ul>
				<ul>
					<li>
						<span class="title">地推名称</span>
						<div class="content">{{$lastsalesmansetdetail['name']}}</div>
					</li>
					<li>
						<span class="title">有效地推定义</span>
						<div class="content">{{$lastsalesmansetdetail['showvalidsalesman']}}</div>
					</li>
					<li>
						<span class="title">地推效果</span>
						<div class="content">
							<span class="count">{{$lastsalesmansetdetail['currentregisternum']}}个注册用户</span>
                        @if($lastsalesmansetdetail['accounttype']==2||$lastsalesmansetdetail['accounttype']==3||$lastsalesmansetdetail['accounttype']==4)
							<span class="count">{{$lastsalesmansetdetail['currentordernum']}}笔地推订单</span>
							<span class="count">地推订单实付：{{$lastsalesmansetdetail['currentordertotalamount']}}</span>
                        @elseif($lastsalesmansetdetail['accounttype'] == 5 || $lastsalesmansetdetail['accounttype']==6)
							<span class="count">{{$lastsalesmansetdetail['currentrechargenum']}}笔充值</span>
                        @endif
							<span class="count">地推收入：￥{{$lastsalesmansetdetail['currenttotalmoney']}}</span>
							<a href="/console/salesman/user/result?salesmanid={{$salesmanid}}&cityid={{$cityid}}&salesmansetid={{$lastsalesmansetid}}">查看效果明细>></a>
						</div>
					</li>
				</ul>
			</li>
		</ul>
    @endif
	</div>
	<form action="" method="" class="prompt_double">
        <img class="fr close_pic" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
        <p class="title">选择新的地推方案</p>
        <p class="content">
        	<span>现地推方案：</span>
        @if(isset($salesmansetdetail['name']))
        	<span>{{$salesmansetdetail['name']}}</span>
        @endif
        </p>
        <p class="content">
        	<span>新地推方案：</span>
        	<select name="salesmansetid" id="">
        		<option value="0">请选择</option>
            @foreach($salesmansetlist as $list)
        		<option value="{{$list['salesmansetid']}}">{{$list['name']}}</option>
            @endforeach
        	</select>
        </p>
        <p class="button oh">
            <input type="button" name="" value="取消" class="fl cancel">
            <input type="button" name="" value="确定" class="fr sure">
        </p>
    </form>
</section>
@endsection

@section('scriptResources')
    @parent
    <script>
    var cityid='{{$cityid}}';
    var salesmanid='{{$salesmanid}}';
    //取消地推
    $(".cancel_salesman").click(function(){
    	$.ajax({
    		url: '/console/salesman/user/status/update',
    		type: 'post',
    		data: {
                'cityid': cityid,
                'salesmanid':salesmanid,
                'status':0
    		},
    		dataType: 'json',
    		success:function(data){
    			if(data.status == 'success'){
                    alert(data.message);
                    window.location.reload();
    			}else{
                    alert(data.message);
    			}
    		}
    	})
    })
    $(".open_salesman").click(function(){
        $.ajax({
            url: '/console/salesman/user/status/update',
            type: 'post',
            data: {
                'cityid': cityid,
                'salesmanid':salesmanid,
                'status':1
            },
            dataType: 'json',
            success:function(data){
                if(data.status == 'success'){
                    alert(data.message);
                    window.location.reload();
                }else{
                    alert(data.message);
                }
            }
        })
    })
    //更改地推方案
    $(".choose_salesman_way").click(function(){
    	$(".prompt_double").show();
    	$(".public_prompt_mark").show();
    	$(".public_prompt_mark").height($(window).height());
    })
    $(".prompt_double .cancel").click(function(){
        $(".public_prompt_mark").hide();
        $(".prompt_double").hide();
    });
    $(".prompt_double .close_pic").click(function(){
        $(".public_prompt_mark").hide();
        $(".prompt_double").hide();
    });
    $(".prompt_double .sure").click(function(){
        var salesmansetidselected = $(".prompt_double select[name='salesmansetid']").find("option:selected").val();
        $.ajax({
        	url:"/console/salesman/user/salesmanset/update",
        	type:"post",
        	data:{
        	    cityid:cityid,
        	    salesmansetid:salesmansetidselected,
        	    salesmanid:salesmanid
        	},
        	dataType:"json",
        	success:function(data){
        		if(data.status == 'success') {
                    alert(data.message);
                    window.location.reload();
                } else {
                    alert(data.message);return;
                }
        	}
        })
    });
    </script>
@endsection